home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  10.0 KB  |  363 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __EVENTS__
  18. #define __EVENTS__
  19.  
  20. #ifndef __OSUTILS__
  21. #include <OSUtils.h>
  22. #endif
  23. #ifndef __QUICKDRAW__
  24. #include <Quickdraw.h>
  25. #endif
  26. #ifndef __MACTYPES__
  27. #include <MacTypes.h>
  28. #endif
  29.  
  30. #if !TARGET_OS_MAC
  31. #ifndef __ENDIAN__
  32. #include <Endian.h>
  33. #endif
  34. #endif  /* !TARGET_OS_MAC */
  35.  
  36.  
  37.  
  38. #if PRAGMA_ONCE
  39. #pragma once
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT
  47. #pragma import on
  48. #endif
  49.  
  50. #if PRAGMA_STRUCT_ALIGN
  51.     #pragma options align=mac68k
  52. #elif PRAGMA_STRUCT_PACKPUSH
  53.     #pragma pack(push, 2)
  54. #elif PRAGMA_STRUCT_PACK
  55.     #pragma pack(2)
  56. #endif
  57.  
  58. typedef UInt16                             EventKind;
  59. typedef UInt16                             EventMask;
  60.  
  61. enum {
  62.     nullEvent                    = 0,
  63.     mouseDown                    = 1,
  64.     mouseUp                        = 2,
  65.     keyDown                        = 3,
  66.     keyUp                        = 4,
  67.     autoKey                        = 5,
  68.     updateEvt                    = 6,
  69.     diskEvt                        = 7,
  70.     activateEvt                    = 8,
  71.     osEvt                        = 15,
  72.     kHighLevelEvent                = 23
  73. };
  74.  
  75.  
  76. enum {
  77.     mDownMask                    = 1 << mouseDown,                /* mouse button pressed*/
  78.     mUpMask                        = 1 << mouseUp,                    /* mouse button released*/
  79.     keyDownMask                    = 1 << keyDown,                    /* key pressed*/
  80.     keyUpMask                    = 1 << keyUp,                    /* key released*/
  81.     autoKeyMask                    = 1 << autoKey,                    /* key repeatedly held down*/
  82.     updateMask                    = 1 << updateEvt,                /* window needs updating*/
  83.     diskMask                    = 1 << diskEvt,                    /* disk inserted*/
  84.     activMask                    = 1 << activateEvt,                /* activate/deactivate window*/
  85.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents)*/
  86.     osMask                        = 1 << osEvt,                    /* operating system events (suspend, resume)*/
  87.     everyEvent                    = 0xFFFF                        /* all of the above*/
  88. };
  89.  
  90.  
  91. enum {
  92.     charCodeMask                = 0x000000FF,
  93.     keyCodeMask                    = 0x0000FF00,
  94.     adbAddrMask                    = 0x00FF0000,
  95.     osEvtMessageMask            = (long)0xFF000000
  96. };
  97.  
  98.  
  99. enum {
  100.                                                                 /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  101.     mouseMovedMessage            = 0x00FA,
  102.     suspendResumeMessage        = 0x0001
  103. };
  104.  
  105.  
  106. enum {
  107.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  108.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change*/
  109. };
  110.  
  111.  
  112. typedef UInt16                             EventModifiers;
  113.  
  114. enum {
  115.                                                                 /* modifiers */
  116.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown)*/
  117.     btnStateBit                    = 7,                            /* state of button?*/
  118.     cmdKeyBit                    = 8,                            /* command key down?*/
  119.     shiftKeyBit                    = 9,                            /* shift key down?*/
  120.     alphaLockBit                = 10,                            /* alpha lock down?*/
  121.     optionKeyBit                = 11,                            /* option key down?*/
  122.     controlKeyBit                = 12,                            /* control key down?*/
  123.     rightShiftKeyBit            = 13,                            /* right shift key down?*/
  124.     rightOptionKeyBit            = 14,                            /* right Option key down?*/
  125.     rightControlKeyBit            = 15                            /* right Control key down?*/
  126. };
  127.  
  128.  
  129. enum {
  130.     activeFlag                    = 1 << activeFlagBit,
  131.     btnState                    = 1 << btnStateBit,
  132.     cmdKey                        = 1 << cmdKeyBit,
  133.     shiftKey                    = 1 << shiftKeyBit,
  134.     alphaLock                    = 1 << alphaLockBit,
  135.     optionKey                    = 1 << optionKeyBit,
  136.     controlKey                    = 1 << controlKeyBit,
  137.     rightShiftKey                = 1 << rightShiftKeyBit,
  138.     rightOptionKey                = 1 << rightOptionKeyBit,
  139.     rightControlKey                = 1 << rightControlKeyBit
  140. };
  141.  
  142.  
  143. enum {
  144.     kNullCharCode                = 0,
  145.     kHomeCharCode                = 1,
  146.     kEnterCharCode                = 3,
  147.     kEndCharCode                = 4,
  148.     kHelpCharCode                = 5,
  149.     kBellCharCode                = 7,
  150.     kBackspaceCharCode            = 8,
  151.     kTabCharCode                = 9,
  152.     kLineFeedCharCode            = 10,
  153.     kVerticalTabCharCode        = 11,
  154.     kPageUpCharCode                = 11,
  155.     kFormFeedCharCode            = 12,
  156.     kPageDownCharCode            = 12,
  157.     kReturnCharCode                = 13,
  158.     kFunctionKeyCharCode        = 16,
  159.     kEscapeCharCode                = 27,
  160.     kClearCharCode                = 27,
  161.     kLeftArrowCharCode            = 28,
  162.     kRightArrowCharCode            = 29,
  163.     kUpArrowCharCode            = 30,
  164.     kDownArrowCharCode            = 31,
  165.     kDeleteCharCode                = 127,
  166.     kNonBreakingSpaceCharCode    = 202
  167. };
  168.  
  169.  
  170. struct EventRecord {
  171.     EventKind                         what;
  172.     UInt32                             message;
  173.     UInt32                             when;
  174.     Point                             where;
  175.     EventModifiers                     modifiers;
  176. };
  177. typedef struct EventRecord                EventRecord;
  178.  
  179. typedef CALLBACK_API( void , FKEYProcPtr )(void );
  180. typedef STACK_UPP_TYPE(FKEYProcPtr)                             FKEYUPP;
  181. enum { uppFKEYProcInfo = 0x00000000 };                             /* pascal no_return_value Func() */
  182. #define NewFKEYProc(userRoutine)                                 (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  183. #define CallFKEYProc(userRoutine)                                 CALL_ZERO_PARAMETER_UPP((userRoutine), uppFKEYProcInfo)
  184. EXTERN_API( void )
  185. GetMouse                        (Point *                mouseLoc)                            ONEWORDINLINE(0xA972);
  186.  
  187. EXTERN_API( Boolean )
  188. Button                            (void)                                                        ONEWORDINLINE(0xA974);
  189.  
  190. EXTERN_API( Boolean )
  191. StillDown                        (void)                                                        ONEWORDINLINE(0xA973);
  192.  
  193. EXTERN_API( Boolean )
  194. WaitMouseUp                        (void)                                                        ONEWORDINLINE(0xA977);
  195.  
  196. EXTERN_API( UInt32 )
  197. TickCount                        (void)                                                        ONEWORDINLINE(0xA975);
  198.  
  199. EXTERN_API( UInt32 )
  200. KeyTranslate                    (const void *            transData,
  201.                                  UInt16                 keycode,
  202.                                  UInt32 *                state)                                ONEWORDINLINE(0xA9C3);
  203.  
  204. EXTERN_API( UInt32 )
  205. GetCaretTime                    (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F4);
  206.  
  207.  
  208. /* 
  209.     QuickTime 3.0 supports GetKeys() on unix and win32
  210.     But, on little endian machines you will have to be
  211.     careful about bit numberings and/or use a KeyMapByteArray
  212.     instead.
  213. */
  214. #if TARGET_OS_MAC
  215.  
  216. typedef UInt32                             KeyMap[4];
  217. #else
  218. typedef BigEndianLong                     KeyMap[4];
  219. #endif  /* TARGET_OS_MAC */
  220.  
  221. typedef UInt8                             KeyMapByteArray[16];
  222. EXTERN_API( void )
  223. GetKeys                            (KeyMap                 theKeys)                            ONEWORDINLINE(0xA976);
  224.  
  225.  
  226.  
  227. /* Obsolete event types & masks */
  228.  
  229. enum {
  230.     networkEvt                    = 10,
  231.     driverEvt                    = 11,
  232.     app1Evt                        = 12,
  233.     app2Evt                        = 13,
  234.     app3Evt                        = 14,
  235.     app4Evt                        = 15,
  236.     networkMask                    = 0x0400,
  237.     driverMask                    = 0x0800,
  238.     app1Mask                    = 0x1000,
  239.     app2Mask                    = 0x2000,
  240.     app3Mask                    = 0x4000,
  241.     app4Mask                    = 0x8000
  242. };
  243.  
  244.  
  245. struct EvQEl {
  246.     QElemPtr                         qLink;
  247.     SInt16                             qType;
  248.     EventKind                         evtQWhat;                    /* this part is identical to the EventRecord as defined above */
  249.     UInt32                             evtQMessage;
  250.     UInt32                             evtQWhen;
  251.     Point                             evtQWhere;
  252.     EventModifiers                     evtQModifiers;
  253. };
  254. typedef struct EvQEl                    EvQEl;
  255. typedef EvQEl *                            EvQElPtr;
  256. typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
  257. /*
  258.     WARNING: GetNextEventFilterProcPtr uses register based parameters under classic 68k
  259.              and cannot be written in a high-level language without 
  260.              the help of mixed mode or assembly glue.
  261. */
  262. typedef REGISTER_UPP_TYPE(GetNextEventFilterProcPtr)             GetNextEventFilterUPP;
  263. enum { uppGetNextEventFilterProcInfo = 0x000000BF };             /* SPECIAL_CASE_PROCINFO(11) */
  264. #define NewGetNextEventFilterProc(userRoutine)                     (GetNextEventFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  265. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  266.     /* CallGetNextEventFilterProc can't be called from classic 68k without glue code */
  267. #else
  268.     #define CallGetNextEventFilterProc(userRoutine, theEvent, result)  CALL_TWO_PARAMETER_UPP((userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  269. #endif
  270.  
  271. typedef GetNextEventFilterUPP             GNEFilterUPP;
  272. EXTERN_API( QHdrPtr )
  273. GetEvQHdr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  274.  
  275. EXTERN_API( UInt32 )
  276. GetDblTime                        (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F0);
  277.  
  278. EXTERN_API( void )
  279. SetEventMask                    (EventMask                 value)                                TWOWORDINLINE(0x31DF, 0x0144);
  280.  
  281.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  282.                                                                                             #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  283.                                                                                             #endif
  284. EXTERN_API( OSErr )
  285. PPostEvent                        (EventKind                 eventCode,
  286.                                  UInt32                 eventMsg,
  287.                                  EvQElPtr *                qEl)                                TWOWORDINLINE(0xA12F, 0x2288);
  288.  
  289. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  290. EXTERN_API( Boolean )
  291. GetNextEvent                    (EventMask                 eventMask,
  292.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA970);
  293.  
  294. EXTERN_API( Boolean )
  295. WaitNextEvent                    (EventMask                 eventMask,
  296.                                  EventRecord *            theEvent,
  297.                                  UInt32                 sleep,
  298.                                  RgnHandle                 mouseRgn) /* can be NULL */            ONEWORDINLINE(0xA860);
  299.  
  300. EXTERN_API( Boolean )
  301. EventAvail                        (EventMask                 eventMask,
  302.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA971);
  303.  
  304.  
  305.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  306.                                                                                             #pragma parameter __D0 PostEvent(__A0, __D0)
  307.                                                                                             #endif
  308. EXTERN_API( OSErr )
  309. PostEvent                        (EventKind                 eventNum,
  310.                                  UInt32                 eventMsg)                            ONEWORDINLINE(0xA02F);
  311.  
  312.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  313.                                                                                             #pragma parameter __D0 OSEventAvail(__D0, __A0)
  314.                                                                                             #endif
  315. EXTERN_API( Boolean )
  316. OSEventAvail                    (EventMask                 mask,
  317.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA030, 0x5240);
  318.  
  319.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  320.                                                                                             #pragma parameter __D0 GetOSEvent(__D0, __A0)
  321.                                                                                             #endif
  322. EXTERN_API( Boolean )
  323. GetOSEvent                        (EventMask                 mask,
  324.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA031, 0x5240);
  325.  
  326. EXTERN_API( void )
  327. FlushEvents                        (EventMask                 whichMask,
  328.                                  EventMask                 stopMask)                            TWOWORDINLINE(0x201F, 0xA032);
  329.  
  330. EXTERN_API( void )
  331. SystemClick                        (const EventRecord *    theEvent,
  332.                                  WindowPtr                 theWindow)                            ONEWORDINLINE(0xA9B3);
  333.  
  334. EXTERN_API( void )
  335. SystemTask                        (void)                                                        ONEWORDINLINE(0xA9B4);
  336.  
  337. EXTERN_API( Boolean )
  338. SystemEvent                        (const EventRecord *    theEvent)                            ONEWORDINLINE(0xA9B2);
  339.  
  340.  
  341.  
  342.  
  343. #if PRAGMA_STRUCT_ALIGN
  344.     #pragma options align=reset
  345. #elif PRAGMA_STRUCT_PACKPUSH
  346.     #pragma pack(pop)
  347. #elif PRAGMA_STRUCT_PACK
  348.     #pragma pack()
  349. #endif
  350.  
  351. #ifdef PRAGMA_IMPORT_OFF
  352. #pragma import off
  353. #elif PRAGMA_IMPORT
  354. #pragma import reset
  355. #endif
  356.  
  357. #ifdef __cplusplus
  358. }
  359. #endif
  360.  
  361. #endif /* __EVENTS__ */
  362.  
  363.